In general, data files are recorded in a storage device in accordance with a rule called a file system for managing the storage locations, attributes, and the like of the data files. Although various kinds of file systems have been known in accordance with the types of OSs and the like, the FAT (File Allocation Table) file system is widely used.
FIG. 2 shows an outline of the area arrangement of a storage device using the FAT system. A management area is set in the head area. The management area comprises a master boot record (MBR), boot sector, FAT, and directory. The management area records basic information concerning the file system, for example, the size of the data area in the storage device and a cluster size representing the minimum logical storage unit in the storage device. The data area follows the management area. In general, data files are saved in the data area.
The most basic procedure for acquiring a data file (IMG—0001.JPG) recorded in the data area will be described below. The file input/output module included in, for example, the OS finds a directory entry block in the storage device first. The file input/output module then searches for IMG—0001.JPG by a file name in the directory entry. Upon finding the directory entry of IMG—0001.JPG, the file input/output module acquires its start cluster.
The file input/output module then refers to an address in the FAT which corresponds to the acquired start cluster and grasps in which chain of clusters (cluster chain) the data file is recorded.
Referring to FIG. 2, it is known from the directory entry that the start cluster of IMG—0001.JPG is cluster 3. Referring to a FAT area corresponding to cluster 3 makes it obvious that “4” is recorded, and file data is also recorded in cluster 4. Referring to a FAT area corresponding to cluster 4 makes it obvious that “5” is recorded. In this manner, the chain of clusters in which the data file is recorded is traced back to the cluster in which “FFFF” is recorded, which indicates the last cluster.
In this case, since “FFFF” is recorded in a FAT area corresponding to cluster 6, it is obvious that IMG—0001.JPG is recorded by using four clusters 3, 4, 5, and 6. In addition, a capacity per cluster allows the size of an area which IMG—0001.JPG uses to be known. That is, if the capacity is 16 KB/cluster, IMG—0001.JPG uses an area with 16 KB*4=64 KB. The file input/output module recognizes in this manner that IMG—0001.JPG exists in clusters 3 to 6, and can acquire the file by reading data from the clusters.
A procedure for saving a new file IMG—0002.JPG in the storage medium will be described next. When newly saving the file, the file input/output module opens the file first. When opening the file, the file input/output module registers a new entry corresponding to the file name (IMG—0002.JPG) in the directory entry area. Note that at this point in time, since the start cluster of the file and the file size are undecided, the directory entry is blank.
The file input/output module then writes the file in blank clusters in the data area. Upon completely writing the data, the file input/output module closes the file. When closing the file, the file input/output module writes a start cluster and a file size in the directory entry, and writes a cluster chain in the FAT area.
As described above, when saving a file, the file input/output module performs at least four writes, that is, a write in a directory entry (at the time of file opening), a write in a data area, and writes in a directory entry and a FAT (at the time of file closing).
Recently, for the purpose of a reduction in the cost of an exchangeable storage medium used for digital cameras and the like, there have been provided storage media with limited numbers of write accesses, for example, write-once storage media. A storage medium with a limited number of write accesses, a write-once storage medium in this case, will be referred to as a limited-rewriteable storage medium.
It is possible to use the FAT file system for a limited-rewriteable storage medium. However, a limited-rewriteable storage medium does not allow updating data within the same writing unit (sector). For this reason, when saving a file in a limited-rewriteable storage medium, it is impossible to use the method described with reference to FIG. 2, without any change, which needs to update a FAT and directory entry within the same sector.
Under the circumstance, a file save procedure for the application of the FAT file system to a limited-rewriteable storage medium has been proposed.
This method will be described with reference to FIG. 3. The method is the same as the above method in that it is necessary to write in a FAT, directory entry, and data area when saving the new file IMG—0002.JPG in a limited-rewriteable storage medium.
Although it suffices to write in available clusters in the data area, management information (the FAT and the directory entry) has already been written. As described above, a limited-rewriteable storage medium which allows a write access only once does not allow once-written data to be overwritten/updated. For this reason, the FAT and directory entry area which have been used are invalidated, and new management information to which information concerning IMG—0002.JPG is added is written in an unused area. In addition, all information including a data size and a start cluster is written in the directory entry at once after a write in the data area instead of at the time of file opening.
This makes it possible to record a file in a limited-rewriteable storage medium based on the FAT file system. However, saving a new file will always consume a capacity for management information other than a data area.
For example, Japanese Patent Laid-Open No. 2003-244606 (D1) has proposed a technique of recording management information in a built-in nonvolatile memory in a camera, together with image data, and recording the image data and the management information in a limited-rewriteable storage medium at once at the timing, for example, when a memory card is ejected.
According to D1, since management information is not written every time a file is created, it is possible to improve the efficiency of use of the limited-rewriteable storage medium. According to D1, however, since both image data and management information are stored in the built-in nonvolatile memory of the camera, if the capacity of the nonvolatile memory is not large, the number of writes in the limited-rewriteable storage medium increases, resulting in a deterioration in the efficiency of use of the storage medium. Recent digital cameras generate large-capacity image data due to an increase in the number of pixels. Therefore, the efficiency of use of a storage medium cannot be effectively improved unless it has a built-in nonvolatile memory with a considerably large capacity. This can cause a large increase in cost.
In addition, the technique disclosed in D1 writes image data when a memory card is ejected or an external device is connected. Therefore, there is a wait time for the next processing until the end of the write. Even if, for example, the user wants to immediately exchange memory cards, he/she must wait until the end of the writing of image data stored in the built-in memory.
On the other hand, in an image capturing apparatus, in order to determine the number of recordable images, it is necessary to know the available space of a storage medium. A unique problem accompanies the use of a limited-rewriteable storage medium. Conventionally, an image capturing apparatus obtains the number of available clusters from the information of the FAT area in a storage medium at the time of startup processing, and calculates the available space of the storage medium by multiplying the obtained number by a cluster size. This apparatus then obtains the number of recordable images based on this available space.
A limited-rewriteable storage medium is configured to allow an image capturing apparatus to use it in the same manner as a general storage medium. For this reason, when an image capturing apparatus uses a limited-rewriteable storage medium, even if the capacity decreases by a capacity corresponding to management information in addition to a capacity corresponding to image data in reality, the apparatus updates the available space upon simply detecting that the capacity has decreased by only the capacity corresponding to the image data.
As a result, a difference appears between the available space calculated by the image capturing apparatus and the actual available space. However, there has been provided no specific method of allowing an image capturing apparatus to accurately grasp the available space of a limited-rewriteable storage medium.